how to write a program that computes powers